package com.ruoyi.feedback.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.feedback.domain.TbFeedback;
import com.ruoyi.feedback.service.ITbFeedbackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户反馈信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-04
 */
@RestController
@RequestMapping("/feedback/feedback")
public class TbFeedbackController extends BaseController
{
    @Autowired
    private ITbFeedbackService tbFeedbackService;

    /**
     * 查询用户反馈信息列表
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbFeedback tbFeedback)
    {
        startPage();
        List<TbFeedback> list = tbFeedbackService.selectTbFeedbackList(tbFeedback);
        return getDataTable(list);
    }

    /**
     * 导出用户反馈信息列表
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:export')")
    @Log(title = "用户反馈信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbFeedback tbFeedback)
    {
        List<TbFeedback> list = tbFeedbackService.selectTbFeedbackList(tbFeedback);
        ExcelUtil<TbFeedback> util = new ExcelUtil<TbFeedback>(TbFeedback.class);
        util.exportExcel(response, list, "用户反馈信息数据");
    }

    /**
     * 获取用户反馈信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tbFeedbackService.selectTbFeedbackById(id));
    }

    /**
     * 新增用户反馈信息
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:add')")
    @Log(title = "用户反馈信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbFeedback tbFeedback)
    {
        return toAjax(tbFeedbackService.insertTbFeedback(tbFeedback));
    }

    /**
     * 修改用户反馈信息
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:edit')")
    @Log(title = "用户反馈信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbFeedback tbFeedback)
    {
        return toAjax(tbFeedbackService.updateTbFeedback(tbFeedback));
    }

    /**
     * 删除用户反馈信息
     */
    @PreAuthorize("@ss.hasPermi('feedback:feedback:remove')")
    @Log(title = "用户反馈信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbFeedbackService.deleteTbFeedbackByIds(ids));
    }
}
